package com.ks.common.exception;

import com.ks.common.enums.BizCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 业务异常
 *
 * @author KingAusten
 * @date 2022/08/17 17:59:46
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class BizException extends RuntimeException{

    /**
     * 编码
     */
    private int code;

    /**
     * 消息
     */
    private String msg;

    public BizException(BizCodeEnum bizCodeEnum){

        this(bizCodeEnum.getCode(),bizCodeEnum.getMsg());
    }

    /**
     * @param code 编码
     * @param msg  消息
     *             <p>
     *             业务异常
     *
     * @return
     */
    public BizException(int code,String msg){

        super(msg);
        this.code = code;
        this.msg = msg;
    }

}
